package fr.mywiki.view.web.servlet;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fr.mywiki.business.file.FileManager;
import fr.mywiki.business.log.LogManager;

/**
 * Servlet used for the asynchronous file upload.
 *
 * @web.servlet            name="FileAsynchronousUpload" 
 * 							display-name="FileAsynchronousUpload"
 * @web.servlet-mapping    url-pattern="/FileAsynchronousUpload"
 * @web.servlet-mapping    url-pattern="/FileAsynchronousUpload.do"
 */
public class FileAsynchronousUploadServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	public static final String FILE_CONTENT = "fileContent";
	public static final String FILE_NAME = "fileName";

	public void doGet(HttpServletRequest request, HttpServletResponse response) {}

	public void doPost(HttpServletRequest request, HttpServletResponse response) {
		byte[] fileContent = request.getParameter(FILE_CONTENT).getBytes();
		try {
			FileManager.uploadFile("toto", fileContent);
		} catch (Exception e) {
			LogManager.println("");
		}
	}
}
